\(\int \tan (e+f x) (a+b \tan ^2(e+f x)) \, dx\) [187]

   Optimal result
   Rubi [A] (verified)
   Mathematica [A] (verified)
   Maple [A] (verified)
   Fricas [A] (verification not implemented)
   Sympy [B] (verification not implemented)
   Maxima [A] (verification not implemented)
   Giac [B] (verification not implemented)
   Mupad [B] (verification not implemented)

Optimal result

Integrand size = 19, antiderivative size = 34 \[ \int \tan (e+f x) \left (a+b \tan ^2(e+f x)\right ) \, dx=-\frac {(a-b) \log (\cos (e+f x))}{f}+\frac {b \tan ^2(e+f x)}{2 f} \]

[Out]

-(a-b)*ln(cos(f*x+e))/f+1/2*b*tan(f*x+e)^2/f

Rubi [A] (verified)

Time = 0.03 (sec) , antiderivative size = 34, normalized size of antiderivative = 1.00, number of steps used = 2, number of rules used = 2, \(\frac {\text {number of rules}}{\text {integrand size}}\) = 0.105, Rules used = {3712, 3556} \[ \int \tan (e+f x) \left (a+b \tan ^2(e+f x)\right ) \, dx=\frac {b \tan ^2(e+f x)}{2 f}-\frac {(a-b) \log (\cos (e+f x))}{f} \]

[In]

Int[Tan[e + f*x]*(a + b*Tan[e + f*x]^2),x]

[Out]

-(((a - b)*Log[Cos[e + f*x]])/f) + (b*Tan[e + f*x]^2)/(2*f)

Rule 3556

Int[tan[(c_.) + (d_.)*(x_)], x_Symbol] :> Simp[-Log[RemoveContent[Cos[c + d*x], x]]/d, x] /; FreeQ[{c, d}, x]

Rule 3712

Int[((a_.) + (b_.)*tan[(e_.) + (f_.)*(x_)])^(m_.)*((A_.) + (C_.)*tan[(e_.) + (f_.)*(x_)]^2), x_Symbol] :> Simp
[C*((a + b*Tan[e + f*x])^(m + 1)/(b*f*(m + 1))), x] + Dist[A - C, Int[(a + b*Tan[e + f*x])^m, x], x] /; FreeQ[
{a, b, e, f, A, C, m}, x] && NeQ[A*b^2 + a^2*C, 0] &&  !LeQ[m, -1]

Rubi steps \begin{align*} \text {integral}& = \frac {b \tan ^2(e+f x)}{2 f}+(a-b) \int \tan (e+f x) \, dx \\ & = -\frac {(a-b) \log (\cos (e+f x))}{f}+\frac {b \tan ^2(e+f x)}{2 f} \\ \end{align*}

Mathematica [A] (verified)

Time = 0.08 (sec) , antiderivative size = 40, normalized size of antiderivative = 1.18 \[ \int \tan (e+f x) \left (a+b \tan ^2(e+f x)\right ) \, dx=-\frac {a \log (\cos (e+f x))}{f}+\frac {b \left (2 \log (\cos (e+f x))+\tan ^2(e+f x)\right )}{2 f} \]

[In]

Integrate[Tan[e + f*x]*(a + b*Tan[e + f*x]^2),x]

[Out]

-((a*Log[Cos[e + f*x]])/f) + (b*(2*Log[Cos[e + f*x]] + Tan[e + f*x]^2))/(2*f)

Maple [A] (verified)

Time = 0.04 (sec) , antiderivative size = 35, normalized size of antiderivative = 1.03

method result size
derivativedivides \(\frac {\frac {b \tan \left (f x +e \right )^{2}}{2}+\frac {\left (a -b \right ) \ln \left (1+\tan \left (f x +e \right )^{2}\right )}{2}}{f}\) \(35\)
default \(\frac {\frac {b \tan \left (f x +e \right )^{2}}{2}+\frac {\left (a -b \right ) \ln \left (1+\tan \left (f x +e \right )^{2}\right )}{2}}{f}\) \(35\)
norman \(\frac {b \tan \left (f x +e \right )^{2}}{2 f}+\frac {\left (a -b \right ) \ln \left (1+\tan \left (f x +e \right )^{2}\right )}{2 f}\) \(37\)
parallelrisch \(\frac {b \tan \left (f x +e \right )^{2}+\ln \left (1+\tan \left (f x +e \right )^{2}\right ) a -\ln \left (1+\tan \left (f x +e \right )^{2}\right ) b}{2 f}\) \(44\)
parts \(\frac {b \left (\frac {\tan \left (f x +e \right )^{2}}{2}-\frac {\ln \left (1+\tan \left (f x +e \right )^{2}\right )}{2}\right )}{f}+\frac {a \ln \left (1+\tan \left (f x +e \right )^{2}\right )}{2 f}\) \(48\)
risch \(i x a -i x b +\frac {2 i a e}{f}-\frac {2 i b e}{f}+\frac {2 b \,{\mathrm e}^{2 i \left (f x +e \right )}}{f \left ({\mathrm e}^{2 i \left (f x +e \right )}+1\right )^{2}}-\frac {\ln \left ({\mathrm e}^{2 i \left (f x +e \right )}+1\right ) a}{f}+\frac {\ln \left ({\mathrm e}^{2 i \left (f x +e \right )}+1\right ) b}{f}\) \(91\)

[In]

int(tan(f*x+e)*(a+b*tan(f*x+e)^2),x,method=_RETURNVERBOSE)

[Out]

1/f*(1/2*b*tan(f*x+e)^2+1/2*(a-b)*ln(1+tan(f*x+e)^2))

Fricas [A] (verification not implemented)

none

Time = 0.30 (sec) , antiderivative size = 36, normalized size of antiderivative = 1.06 \[ \int \tan (e+f x) \left (a+b \tan ^2(e+f x)\right ) \, dx=\frac {b \tan \left (f x + e\right )^{2} - {\left (a - b\right )} \log \left (\frac {1}{\tan \left (f x + e\right )^{2} + 1}\right )}{2 \, f} \]

[In]

integrate(tan(f*x+e)*(a+b*tan(f*x+e)^2),x, algorithm="fricas")

[Out]

1/2*(b*tan(f*x + e)^2 - (a - b)*log(1/(tan(f*x + e)^2 + 1)))/f

Sympy [B] (verification not implemented)

Leaf count of result is larger than twice the leaf count of optimal. 60 vs. \(2 (26) = 52\).

Time = 0.09 (sec) , antiderivative size = 60, normalized size of antiderivative = 1.76 \[ \int \tan (e+f x) \left (a+b \tan ^2(e+f x)\right ) \, dx=\begin {cases} \frac {a \log {\left (\tan ^{2}{\left (e + f x \right )} + 1 \right )}}{2 f} - \frac {b \log {\left (\tan ^{2}{\left (e + f x \right )} + 1 \right )}}{2 f} + \frac {b \tan ^{2}{\left (e + f x \right )}}{2 f} & \text {for}\: f \neq 0 \\x \left (a + b \tan ^{2}{\left (e \right )}\right ) \tan {\left (e \right )} & \text {otherwise} \end {cases} \]

[In]

integrate(tan(f*x+e)*(a+b*tan(f*x+e)**2),x)

[Out]

Piecewise((a*log(tan(e + f*x)**2 + 1)/(2*f) - b*log(tan(e + f*x)**2 + 1)/(2*f) + b*tan(e + f*x)**2/(2*f), Ne(f
, 0)), (x*(a + b*tan(e)**2)*tan(e), True))

Maxima [A] (verification not implemented)

none

Time = 0.24 (sec) , antiderivative size = 37, normalized size of antiderivative = 1.09 \[ \int \tan (e+f x) \left (a+b \tan ^2(e+f x)\right ) \, dx=-\frac {{\left (a - b\right )} \log \left (\sin \left (f x + e\right )^{2} - 1\right ) + \frac {b}{\sin \left (f x + e\right )^{2} - 1}}{2 \, f} \]

[In]

integrate(tan(f*x+e)*(a+b*tan(f*x+e)^2),x, algorithm="maxima")

[Out]

-1/2*((a - b)*log(sin(f*x + e)^2 - 1) + b/(sin(f*x + e)^2 - 1))/f

Giac [B] (verification not implemented)

Leaf count of result is larger than twice the leaf count of optimal. 402 vs. \(2 (32) = 64\).

Time = 0.57 (sec) , antiderivative size = 402, normalized size of antiderivative = 11.82 \[ \int \tan (e+f x) \left (a+b \tan ^2(e+f x)\right ) \, dx=-\frac {a \log \left (\frac {4 \, {\left (\tan \left (f x\right )^{2} \tan \left (e\right )^{2} - 2 \, \tan \left (f x\right ) \tan \left (e\right ) + 1\right )}}{\tan \left (f x\right )^{2} \tan \left (e\right )^{2} + \tan \left (f x\right )^{2} + \tan \left (e\right )^{2} + 1}\right ) \tan \left (f x\right )^{2} \tan \left (e\right )^{2} - b \log \left (\frac {4 \, {\left (\tan \left (f x\right )^{2} \tan \left (e\right )^{2} - 2 \, \tan \left (f x\right ) \tan \left (e\right ) + 1\right )}}{\tan \left (f x\right )^{2} \tan \left (e\right )^{2} + \tan \left (f x\right )^{2} + \tan \left (e\right )^{2} + 1}\right ) \tan \left (f x\right )^{2} \tan \left (e\right )^{2} - b \tan \left (f x\right )^{2} \tan \left (e\right )^{2} - 2 \, a \log \left (\frac {4 \, {\left (\tan \left (f x\right )^{2} \tan \left (e\right )^{2} - 2 \, \tan \left (f x\right ) \tan \left (e\right ) + 1\right )}}{\tan \left (f x\right )^{2} \tan \left (e\right )^{2} + \tan \left (f x\right )^{2} + \tan \left (e\right )^{2} + 1}\right ) \tan \left (f x\right ) \tan \left (e\right ) + 2 \, b \log \left (\frac {4 \, {\left (\tan \left (f x\right )^{2} \tan \left (e\right )^{2} - 2 \, \tan \left (f x\right ) \tan \left (e\right ) + 1\right )}}{\tan \left (f x\right )^{2} \tan \left (e\right )^{2} + \tan \left (f x\right )^{2} + \tan \left (e\right )^{2} + 1}\right ) \tan \left (f x\right ) \tan \left (e\right ) - b \tan \left (f x\right )^{2} - b \tan \left (e\right )^{2} + a \log \left (\frac {4 \, {\left (\tan \left (f x\right )^{2} \tan \left (e\right )^{2} - 2 \, \tan \left (f x\right ) \tan \left (e\right ) + 1\right )}}{\tan \left (f x\right )^{2} \tan \left (e\right )^{2} + \tan \left (f x\right )^{2} + \tan \left (e\right )^{2} + 1}\right ) - b \log \left (\frac {4 \, {\left (\tan \left (f x\right )^{2} \tan \left (e\right )^{2} - 2 \, \tan \left (f x\right ) \tan \left (e\right ) + 1\right )}}{\tan \left (f x\right )^{2} \tan \left (e\right )^{2} + \tan \left (f x\right )^{2} + \tan \left (e\right )^{2} + 1}\right ) - b}{2 \, {\left (f \tan \left (f x\right )^{2} \tan \left (e\right )^{2} - 2 \, f \tan \left (f x\right ) \tan \left (e\right ) + f\right )}} \]

[In]

integrate(tan(f*x+e)*(a+b*tan(f*x+e)^2),x, algorithm="giac")

[Out]

-1/2*(a*log(4*(tan(f*x)^2*tan(e)^2 - 2*tan(f*x)*tan(e) + 1)/(tan(f*x)^2*tan(e)^2 + tan(f*x)^2 + tan(e)^2 + 1))
*tan(f*x)^2*tan(e)^2 - b*log(4*(tan(f*x)^2*tan(e)^2 - 2*tan(f*x)*tan(e) + 1)/(tan(f*x)^2*tan(e)^2 + tan(f*x)^2
 + tan(e)^2 + 1))*tan(f*x)^2*tan(e)^2 - b*tan(f*x)^2*tan(e)^2 - 2*a*log(4*(tan(f*x)^2*tan(e)^2 - 2*tan(f*x)*ta
n(e) + 1)/(tan(f*x)^2*tan(e)^2 + tan(f*x)^2 + tan(e)^2 + 1))*tan(f*x)*tan(e) + 2*b*log(4*(tan(f*x)^2*tan(e)^2
- 2*tan(f*x)*tan(e) + 1)/(tan(f*x)^2*tan(e)^2 + tan(f*x)^2 + tan(e)^2 + 1))*tan(f*x)*tan(e) - b*tan(f*x)^2 - b
*tan(e)^2 + a*log(4*(tan(f*x)^2*tan(e)^2 - 2*tan(f*x)*tan(e) + 1)/(tan(f*x)^2*tan(e)^2 + tan(f*x)^2 + tan(e)^2
 + 1)) - b*log(4*(tan(f*x)^2*tan(e)^2 - 2*tan(f*x)*tan(e) + 1)/(tan(f*x)^2*tan(e)^2 + tan(f*x)^2 + tan(e)^2 +
1)) - b)/(f*tan(f*x)^2*tan(e)^2 - 2*f*tan(f*x)*tan(e) + f)

Mupad [B] (verification not implemented)

Time = 11.67 (sec) , antiderivative size = 37, normalized size of antiderivative = 1.09 \[ \int \tan (e+f x) \left (a+b \tan ^2(e+f x)\right ) \, dx=\frac {b\,{\mathrm {tan}\left (e+f\,x\right )}^2}{2\,f}+\frac {\ln \left ({\mathrm {tan}\left (e+f\,x\right )}^2+1\right )\,\left (\frac {a}{2}-\frac {b}{2}\right )}{f} \]

[In]

int(tan(e + f*x)*(a + b*tan(e + f*x)^2),x)

[Out]

(b*tan(e + f*x)^2)/(2*f) + (log(tan(e + f*x)^2 + 1)*(a/2 - b/2))/f